package game.login;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.security.MessageDigest;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.org.apache.xml.internal.security.utils.Base64;

public class LoginAction extends HttpServlet{
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		MessageDigest md = null;
		String id = (String) request.getParameter("id");
		String password = (String) request.getParameter("password");
		System.out.println("id = " + id + ", password = " + password);
		try {
			md = MessageDigest.getInstance("SHA-256");
			byte mdResult[] = md.digest(password.getBytes());
			String encPassword = Base64.encode(mdResult);
			System.out.println(encPassword);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
